<!DOCTYPE html>
<html>
	<head>
		<title>intercom.js Example</title>
		<link rel="stylesheet" type="text/css" href="stylesheet.css">
		<!--[if IE]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
		<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
		<!--script src="http://192.168.1.120/socket.io/socket.io.js"></script -->
		<script src="../intercom.js"></script>
		<script>
		$(function() {
			if (Intercom.supported) {
				var title = document.title;

				var $messages       = $('#messages');
				var $form_broadcast = $('#form-broadcast');
				var $input_message  = $('#input-message');
				var $input_submit   = $('#input-broadcast');

				var intercom = new Intercom();

				intercom.on('notice', function(data) {
					$messages.append($('<p>').text(data.message));
					document.title = '(' + $messages[0].childNodes.length + ') ' + title;
				});

				$form_broadcast.on('submit', function(e) {
					e.preventDefault();
					intercom.emit('notice', {message: $input_message.val()})
					return false;
				});
			} else {
				alert('intercom.js is not supported by your browser.');
			}
		});
		</script>
	</head>
	<body>
		<h1>intercom.js Example</h1>
		<div class="intro">
			<p>Open this page up in a few tabs!</p>
			<p><strong>Note:</strong> this must be run on a server, it cannot be running of your filesystem.</p>
		</div>
		<form id="form-broadcast" method="post" action="#">
			<input type="text" id="input-message">
			<input type="submit" id="input-broadcast" value="Broadcast">
		</form>
		<div id="messages"></div>
	</body>
</html>